{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "cf8b52b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "\n",
    "odds = [ 1, 3, 5, 7, 9,11,13,15,17,19,\n",
    "        21,23,25,27,29,31,33,35,37,39,\n",
    "        41,43,45,47,49,51,53,55,57,59 ]\n",
    "\n",
    "right_this_minute = datetime.datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "        print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b40e644b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n",
      "现在是秒/时间为奇数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "# print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().second\n",
    "\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在是秒/时间为奇数\")\n",
    "else:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在秒/时间为偶数\")\n",
    "\n",
    "# print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "c763dfd9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\86181'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> import os\n",
    "\n",
    ">>> os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8d5d2d5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 9, 27)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> import datetime\n",
    ">>> datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4d2770f6",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'weather'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [20]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mweather\u001b[39;00m\n\u001b[0;32m      2\u001b[0m weather\u001b[38;5;241m.\u001b[39mbeijing()\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'weather'"
     ]
    }
   ],
   "source": [
    ">>> import weather\n",
    ">>> weather.beijing()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "772561a4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> import datetime\n",
    ">>> datetime.date.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "aba5a9ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'21:03'"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> import time\n",
    ">>> time.strftime(\"%H:%M\")\n",
    "#小时%H 分钟%M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "3fae6914",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Tuesday PM'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> time.strftime(\"%A %p\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "618a1f1b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2022-09-27'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> datetime.date.isoformat(datetime.date.today())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "0de60832",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'today' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [43]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[43mtoday\u001b[49m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSaturday\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[0;32m      2\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mparty!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m      3\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m today \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSunday\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n",
      "\u001b[1;31mNameError\u001b[0m: name 'today' is not defined"
     ]
    }
   ],
   "source": [
    "if today == \"Saturday\":\n",
    "    print(\"party!\")\n",
    "elif today == \"Sunday\":\n",
    "    print(\"recover\")\n",
    "else:\n",
    "    print(\"work\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b1ee9d2f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
